Confusion Matrix

Confusion Matrix

confusion-matrix-1.png|300
source

Performance measures

Accuracy

= the fraction of the total samples that were correctly classified by the classifier

(TP+TN)/(TP+TN+FP+FN)

Misclassification Rate/Classification Error

= the fraction of predictions were incorrect

(FP+FN)/(TP+TN+FP+FN)$$or$$(1Accuracy)

Precision

= the fraction of predictions as a positive class were actually positive

TP/(TP+FP)

Sensitivity / True Positive Rate (TPR) / Probability of Detection / Recall

= the fraction of all positive samples were correctly predicted as positive by the classifier

TP/(TP+FN)

Specificity / True Negative Rate (TNR)

= the fraction of all negative samples are correctly predicted as negative by the classifier

TN/(TN+FP)
Interesting

In clinical studies, accuracy can be seen as a weighted sum of sensitivity and specificity:

accuracy = sensitivity x prevalence + specificity x (1 - prevalence)

where prevalence represents the probability of a disease (positive).

F1-score:

= It combines precision and recall into a single measure. Mathematically it’s the harmonic mean of precision and recall (range in [0,1])

F1 score=2×Precision×SensitivityPrecision+Sensitivity
The Hundred-Page Machine Learning Book

How to choose between precision and sensitivity

  • by assigning a higher weighting to the examples of (the SVM algorithm accepts weightings of classes as input)
  • by tuning hyperparameters to maximize precision or recall on the validation set
  • by varying the decision threshold for algorithms that return probabilities of classes; for instance, if we use logistic regression or decision tree, to increase precison

Cumulative Accuracy Profile (CAP)

resource: https://waleblaq.medium.com/the-cap-curves-the-cumulative-accuracy-profile-58a141e01fae

CAP Analysis

We can analyze the cap curve in 2 ways.

Way 1: ratio of the areas under the good model to the area under the ideal curve

assets/images/confusion-matrix-2.png|500

Way 2:

/assets/images/confusion-matrix-3.png|500

Receiver Operating Characteristic (ROC)